import React, { useEffect } from "react";
import style from "./style.module.scss";
import { MyNavBar } from "../../../components";
import { Custom } from "../Custom";
import { Rate, Field, Image } from "react-vant";
import { useSelector } from "react-redux/es/hooks/useSelector";
import { useAppSelector } from "../../../store/hooks";

import axios from "axios";
import { useRequest, useSetState } from "ahooks";
import { getHttp } from "../../../api/index";

interface CurrentInquiryRecordParams {
  inquiryRecordId: number;
  doctorId: number;
  evaluate: string;
  majorDegree: number;
  satisfactionDegree: number;
}

const Index: React.FC = () => {
  const userId = useAppSelector((state) => state.user.doctor.userName);
  const sessionId = useAppSelector((state) => state.user.doctor.sessionId);
  const [inquiryParams, setInquiryParams] = useSetState({
    userId: userId,
    sessionId: sessionId,
  });
  const recordId = useAppSelector((state) => state.doctor.recordId);
  console.log(recordId); //可以拿到 值为6146

  const findGiftLists = () =>
    getHttp("/health/doctor/inquiry/verify/v1/findDoctorEvaluate", {
      recordId,
    });

  // console.log(recordId, inquiryParams, "bbbbbbbbb");

  const { data: states = [], run } = useRequest(
    async () => {
      const resp = await findGiftLists();
      console.log(resp, "aaaaaaaaaaaaaaaaaaaa");

      return resp.result;
    },
    {
      manual: true,
    }
  );

  useEffect(() => {
    run();
  }, [userId, sessionId]);

  return (
    <div className={style.div}>
      <div className={style["container"]}>
        <MyNavBar title="历史评价" onClickLeft={() => window.history.back()} />
        <Custom title="文字评价" />
        <Field rows={1} value={states.content} type="textarea" />
        <div className={style["containers"]}>
          <Custom title="星级评价" />
          <div className={style["rate"]}>
            <div>
              <p>医师专业度</p>
              <Rate value={states.majorDegree} color="rgb(38,112,229)" />
            </div>
            <div>
              <p>服务满意度</p>
              <Rate value={states.satisfactionDegree} color="rgb(38,112,229)" />
            </div>
          </div>
        </div>
        {states.giftPicUrl ? (
          <div>
            <Custom title="礼物" />
            <Image width={80} height={80} src={states.giftPicUrl} />
          </div>
        ) : (
          <div>
            <Custom title="礼物" />
            <h4 style={{ margin: "20px" }}>还没有礼物哦</h4>
          </div>
        )}
      </div>
    </div>
  );
};

export default Index;
